home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes reversed ƒ / Scissors reversed.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  101 lines

  1. /**********************************************************************\
  2.  
  3. File:        Scissors reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 3
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short ScissorsReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* A region in two parts, starting at the middle of the bottom side and working
  34.    toward the bottom corners, then up the left and right sides. */
  35.    
  36. pascal short ScissorsReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  37. {
  38.     RgnHandle    curregion;
  39.     int            cx,gap,lastx,lasty;
  40.     int            BlockSize;
  41.     
  42.     BlockSize=theWindowHeight/25;
  43.     cx = theWindowWidth / 2;
  44.  
  45.     curregion=NewRgn();
  46.     lastx=theWindowWidth/2;
  47.     gap=theWindowWidth/2+BlockSize;
  48.     do
  49.     {
  50.         StartTiming();
  51.         SetEmptyRgn(curregion);
  52.         MoveTo(cx,0);
  53.         OpenRgn();
  54.             LineTo(lastx,theWindowHeight);        /* get the right half on bottom side */
  55.             LineTo(gap,theWindowHeight);
  56.             LineTo(cx,0);
  57.             LineTo(theWindowWidth-lastx,theWindowHeight);    /* left 1/2 on bottom */
  58.             LineTo(theWindowWidth-gap,theWindowHeight);
  59.             LineTo(cx,0);
  60.         CloseRgn(curregion);
  61.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  62.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  63.             &boundsRect, &boundsRect, 0, curregion);
  64.         lastx=gap;
  65.         gap+=BlockSize;
  66.         TimeCorrection(CorrectTime);
  67.     }
  68.     while (gap<=theWindowWidth+BlockSize);
  69.     
  70.     gap=theWindowHeight-BlockSize;
  71.     lasty=theWindowHeight;
  72.     do
  73.     {
  74.         StartTiming();
  75.         SetEmptyRgn(curregion);
  76.         MoveTo(cx,0);
  77.         OpenRgn();
  78.             LineTo(theWindowWidth,lasty);   /* get the right half */
  79.             LineTo(theWindowWidth,gap);
  80.             LineTo(cx,0);
  81.             LineTo(0,lasty);                   /* get the left half */
  82.             LineTo(0,gap);
  83.             LineTo(cx,0);
  84.         CloseRgn(curregion);
  85.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  86.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  87.             &boundsRect, &boundsRect, 0, curregion);
  88.         lasty=gap;
  89.         gap-=BlockSize;
  90.         TimeCorrection(CorrectTime);
  91.     }
  92.     while (gap>=0);
  93.     
  94.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  95.         &boundsRect, &boundsRect, 0, 0L);        /* if we missed any bits */
  96.     
  97.     DisposeRgn(curregion);
  98.     
  99.     return 0;
  100. }
  101.